﻿namespace Smark.Core
{
    using System;
    using System.IO;
    using System.Runtime.CompilerServices;
    using System.Runtime.Remoting.Messaging;

    public class File
    {
        public void AsynSave(string filename)
        {
            new Action<string>(this.Save).BeginInvoke(filename, delegate (IAsyncResult iar) {
                ((Action<string>) ((AsyncResult) iar).AsyncDelegate).EndInvoke(iar);
            }, null);
        }

        public void Save(string filename)
        {
            using (FileStream stream = System.IO.File.Open(filename, FileMode.Create, FileAccess.Write))
            {
                stream.Write(this.Data, 0, this.Data.Length);
                stream.Flush();
                stream.Close();
            }
        }

        public byte[] Data { get; set; }

        public string FileType { get; set; }

        public string Name { get; set; }

        public long Size { get; set; }
    }
}

